#include "addfloordialog.h"
#include "ui_addfloordialog.h"

addFloorDialog::addFloorDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::addFloorDialog)
{
    ui->setupUi(this);
    
    ui->lineEdit->setText("新建楼层");
    
    connect(ui->cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateBtn()));
    connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(getFloorName()));
    connect(ui->OKBtn, SIGNAL(clicked(bool)), this, SLOT(accept()));
}

addFloorDialog::~addFloorDialog()
{
    delete ui;
}

void addFloorDialog::updateBtn()
{
    if(ui->lineEdit->text().isEmpty())
        ui->OKBtn->setEnabled(false);
    else {
        ui->OKBtn->setEnabled(true);
    }
}

void addFloorDialog::getFloorName()
{
    if(!ui->lineEdit->text().isEmpty())
        this->floorName = ui->lineEdit->text();
}
